#include "fileunit.h"

FileUnit::FileUnit(QObject *parent) : QObject(parent)
{

}

void FileUnit::setFilePath(QString path)
{
    filePath = path;
}

QByteArray FileUnit::readBin(QString path)
{
    filePath = path;

    QFile file(filePath);
    file.open(QIODevice::ReadOnly);
    QByteArray t = file.readAll();
//    uint8_t data[16];
//    for (long i=0;i<0x230;i+=16) {
//        file.seek(i);
//        file.read((char *)data, 16);
//        qDebug("%02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X",
//               (uint8_t)data[0],(uint8_t)data[1],(uint8_t)data[2],(uint8_t)data[3],(uint8_t)data[4],(uint8_t)data[5],(uint8_t)data[6],(uint8_t)data[7],(uint8_t)data[8],(uint8_t)data[9],(uint8_t)data[10],(uint8_t)data[11],(uint8_t)data[12],(uint8_t)data[13],(uint8_t)data[14],(uint8_t)data[15]);

//    }
    file.close();
    return t;
}


bool FileUnit::fileExists(QString path)
{
    filePath = path;
    QFileInfo file(filePath);
    if(file.exists()==false)
    {
        return false;
    }
    else {
        return true;
    }
}


